package main.java.Fzy.designMode.single;

/**
* @author LazyCat
* @date  2022/10/3
* @param
* @return
 * 双重锁检验
*/
public class Single4 {

//    private volatile static Single4 single4;
//
//    private Single4(){}
//
//    public static Single4 getInstance(){
//
//        if(single4 == null){
//            synchronized (Single4.class){
//                if(single4 == null){
//                    single4 = new Single4();
//                }
//            }
//        }
//
//        return single4;
//    }

    private volatile static Single4 single4;

    private Single4(){}

    public static Single4 getInstance(){

        if (single4 == null){
            synchronized (Single4.class){
                if(single4 == null){
                    single4 = new Single4();
                }
            }
        }
        return single4;
    }
}
